<?php


namespace app\common\model;


use think\Model;
use think\model\concern\SoftDelete;

class Detail extends Model
{
    //软删除
    use SoftDelete;
    //映射主键

    // 关联商品表
    public function dish()
    {
        //多对一
        return $this->belongsTo('Dish','dish_id','id');
    }

    public function _update($data)
    {
        if (isset($data['id'])){
            //修改
            return $this->save($data,['id' => $data['id']]);
        }else{
            //添加
            return $this->save($data);
        }
    }
}